<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%@ include file="/pub/head.inc"%>
    <title>信息编辑</title>
</head>
<body>
 	<div id="tabcontainer" style="margin:3px;">
     	<div title="Base Info" tabid="mainTab">
        	<form id="mainform" method="post"></form> 
    	</div>
   	</div>
  	<script type="text/javascript">
  		var pkId = '${id}';
  		//tab
  		var tab = $("#tabcontainer").ligerTab();
  		var baseUrl = '${baseURL}/node/node';
  		
        //定义表单按钮
        LG.setFormDefaultBtn(FF_Cancel, FF_Save);
      	//表单渲染
	  	var mainform = $("#mainform");
        mainform.ligerForm({ 
	        fields: [
			    { name: "id", type: "hidden" },
				{ display: "位置", name: "position", newline: true, labelWidth: 100, width: 220, space: 30, type: "text" ,
			        	validate: { required: true, maxlength: 256}},
				{ display: "描述", name: "description", newline: true, labelWidth: 100, width: 220, space: 30, type: "text" ,
			        	validate: { required: true, maxlength: 516}},
				{ display: "名称", name: "name", newline: true, labelWidth: 100, width: 220, space: 30, type: "text" ,
			        	validate: { required: true, maxlength: 128}},
				{ display: "编码", name: "code", newline: true, labelWidth: 100, width: 220, space: 30, type: "text" ,
			        	validate: { required: true, maxlength: 64}}
	 		],
	        toJSON: JSON2.stringify
        });
     
      	//jquery验证
    	jQuery.metadata.setType("attr", "validate"); 
     	LG.validate(mainform);
     	
     	//保存方法
     	function FF_Save(){
        	mainform.attr("action",baseUrl+"save/save.do?id=${id}");
        	LG.submitForm(mainform, function (data) {
        		var win = parent || window;
                if (data && data.hasOk) {  
                    jQuery.ligerDialog.success('保存成功!');
                    win.LG.closeAndReloadParent("NodeEdit", "${param.menuId}");
                } else { 
     				jQuery.ligerDialog.error("操作失败:\n" + msg.message + "\n请联系管理员!");
                }
            });
    	}
     	
     	//取消方法
	    function FF_Cancel(){
	    	var win = parent || window;
	        win.LG.closeCurrentTab("NodeEdit");
	    }
	    
     	//表单加载后回调函数
     	function FF_AfterLoaded(){
    	 	//do noting
     	}
  	</script>
  	<script type="text/javascript">
      	//load data
      	LG.loadForm({mainForm: mainform, 
    		url:baseUrl + 'edit/editJSON.do?id=${id}', callback: FF_AfterLoaded});
  	</script>
</body>
</html>